package com.example.t1p3;

import java.util.LinkedList;

public class Game {
	
	private Team team1;
	private Team team2;
	private LinkedList<Goal> listGoal;
	private int period;
	
	public Game(){
		setTeam1(new Team());
		setTeam2(new Team());
		setListGoal(new LinkedList<Goal>());
		period = 1;
	}

	public int getPeriod() {
		return period;
	}

	public void setPeriod(int period) {
		this.period = period;
	}

	public Team getTeam2() {
		return team2;
	}

	public void setTeam2(Team team2) {
		this.team2 = team2;
	}

	public Team getTeam1() {
		return team1;
	}

	public void setTeam1(Team team1) {
		this.team1 = team1;
	}

	public LinkedList<Goal> getListGoal() {
		return listGoal;
	}

	public void setListGoal(LinkedList<Goal> listGoal) {
		this.listGoal = listGoal;
	}

	public Team getTeam (String nom){
		if(team1.getNom().equals(nom)){
			return team1;
		}else if(team2.getNom().equals(nom)){
			return team2;
		}else {
			return null;
		}
		
	}
	
	public void score(Goal goal){
		if(goal.getTeam().equals(getTeam1())){
			team1.setScore(team1.getScore()+1);
		}else if(goal.getTeam().equals(getTeam2())){
			team2.setScore(team2.getScore()+1);
		}
		this.getListGoal().add(goal);
	}
}
